#pragma once

#include <iostream>
#include <functional>
using namespace std;



class Task
{
public:
    using func_t = function<int(int, int, char)>;
    // typedef function<int(int, int, char)> func_t;      // 作用和上面一模一样
public:
    Task()
    {
    }

    Task(int x, int y, char op, func_t func)
        : _x(x), _y(y), _op(op), _func(func)
    {
    }

    ~Task()
    {
    }

    string operator()()
    {
        int result = _func(_x, _y, _op);
        char taskname[64];
        snprintf(taskname, sizeof(taskname), "%d %c %d = %d", _x, _op, _y, result);
        return taskname;
    }

    string task_to_string()
    {
        char taskname[64];
        snprintf(taskname, sizeof(taskname), "%d %c %d = ?", _x, _op, _y);
        return taskname;
    }

public:
    int _x;
    int _y;
    char _op;
    func_t _func;
};